//
//  SeAlertView.m
//  Screen
//
//  Created by season02 on 5/17/16.
//  Copyright © 2016 season02. All rights reserved.
//

#import "SeAlertView.h"
#import "UIKit/UIAlertView.h"
//#import "UIKit/UIAlertController.h"

@implementation SeAlertView

+(void)show:(NSString*)title message:(NSString*)message duration:(NSInteger)duraion
{
//    UIAlertController *alert = [UIAlertController alertControllerWithTitle:title message:message preferredStyle:UIAlertControllerStyleAlert];
    
    UIAlertView* alert = [[UIAlertView alloc] initWithTitle:title message:message delegate:self cancelButtonTitle:nil otherButtonTitles: nil];
    [self scheduledTimerWithTimeInterval:1.5 repeats:NO callback:^(void)
     {
         [alert dismissWithClickedButtonIndex:0 animated:YES];
     }];
    [alert show];
//    [self presentViewController:alert animated:YES completion:nil];
}

+(NSTimer *)scheduledTimerWithTimeInterval:(NSTimeInterval)interval
                                    repeats:(BOOL)repeats
                                   callback:(SeVoidBlock)callback
{
    return [NSTimer scheduledTimerWithTimeInterval:interval
                                            target:self
                                          selector:@selector(onTimerUpdateBlock:)
                                          userInfo:[callback copy]
                                           repeats:repeats];
}

+(void)onTimerUpdateBlock:(NSTimer *)timer
{
    SeVoidBlock block = timer.userInfo;
    
    if (block)
    {
        block();
    }
}

@end
